/**
 * 
 */
package com.klxedu.ms.gateway.security.authentication;

import javax.servlet.http.HttpServletRequest;

import org.springframework.security.core.SpringSecurityCoreVersion;
import org.springframework.security.web.authentication.WebAuthenticationDetails;
import org.springframework.util.StringUtils;

import com.klxedu.ms.gateway.AuthServerConstants;
import com.klxedu.ms.gateway.TenancyConfiguration;

 /**
 * Title: CustomWebAuthenticationDetails<br>
 * Description:判断访问方式，默认为pc <br>
 * Copyright @ 2011~2017 Goldgov .All rights reserved.<br>
 * 
 * @author GuoR
 * @createDate 2017年6月7日
 */
public class CustomWebAuthenticationDetails extends WebAuthenticationDetails{
	private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;

	private String client;
	public String getClient() {
		return client;
	}
	public void setClient(String client) {
		this.client = client;
	}
	public CustomWebAuthenticationDetails(HttpServletRequest request) {
		super(request);
		client = request.getParameter("client");
		TenancyConfiguration.setTenancy(request.getHeader(AuthServerConstants.HOST_HEADER_KEY));//设置多租户host
		if(StringUtils.hasText(client)) {
			client = client.toLowerCase();
		}else {
			client = "pc";
		}
	}

}
